package com.wanshi.mapper;


import com.wanshi.entity.Cust;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface CustMapper {
    /*
        username gender birthday phonenum email hobby TYPE introduce
         */

    //查询所有
    @Select("select * from cust order by id desc ")
    List<Cust> list();

    //添加
    @Insert("insert into cust values(null,#{username},#{gender},#{birthday},#{phonenum},#{email},#{hobby},#{type},#{introduce})")
    void addUser(Cust cust);

    //模糊查询
    List<Cust> findByCond(Cust cust);


    //删除
    @Delete("delete from cust where id = #{id}")
    int delUser(int id);

    //批量删除
    void delBatch(String[] ids);

    //根据id查询
    @Select("select * from cust where id = #{id}")
    Cust findUserById(int id);

    //修改用户
    void update(Cust cust);


    @Update("update cust set username=#{username},gender=#{gender},birthday=#{birthday}," +
            "phonenum=#{phonenum},email=#{email},hobby=#{hobby},type=#{type}" +
            "where id = #{id}")
    void updateBatch(Cust cust);
}
